home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / artAttrInitPaintableAttr.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.4 KB  |  131 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. // Alias|Wavefront Script File
  19. // MODIFY THIS AT YOUR OWN RISK
  20. //
  21. // Creation Date:  May 2000 
  22. //
  23. //  Procedure Name:
  24. //      artAttrInitPaintableAttr    
  25. //
  26. //  Description:
  27. //        Initializes the paintable attribute.
  28. //
  29. //  Return Value:
  30. //      0 - if the selection failed.
  31. //      1 - if the selection succeded.
  32. //
  33. global string $gArtAttrFilterLabel = "Filter: all";
  34. global string $gArtAttrCurrentAttr = "";  // Currently selected paintable attr.
  35.  
  36. proc int artAttrValidateAttr(
  37.     string $attribute
  38. )
  39. // Validate that the attribute is paintable.
  40. {
  41.     string $buf[];
  42.     tokenize($attribute, ".", $buf);
  43.     if (size($buf) < 3) 
  44.         return 0;
  45.  
  46.     $attr = $buf[0] + "." + $buf[1] + "." + $buf[2];
  47.     string $isPaintableCmd = "makePaintable -q " + $buf[0] + " " + $buf[2];
  48.     int    $isPaintable[] = eval($isPaintableCmd);
  49.  
  50.     return size($isPaintable); 
  51. }
  52.  
  53.  
  54. proc int artAttrFindFirstPaintableAttr()
  55. {
  56.     string $artCmd = "artAttrCtx";
  57.  
  58.     string $attr = "";
  59.     string $cmd = $artCmd + " -q -objattrArray " + `currentCtx`;
  60.     string $paintAttr = `eval $cmd`;
  61.     string $ListPaintableItem[];
  62.     tokenize( $paintAttr, " ", $ListPaintableItem );
  63.     if (size($ListPaintableItem) < 1) {
  64.         return 0;
  65.     }
  66.  
  67.     for ($paintableItem in $ListPaintableItem) {
  68.         string $buf[];
  69.         tokenize($paintableItem, ".", $buf);
  70.         if (size($buf) < 3) {
  71.             continue;
  72.         }
  73.  
  74.         $attr = $buf[0] + "." + $buf[1] + "." + $buf[2];
  75.  
  76.         //skip vertexColorRGB and vertexFaceColorRGB attrs as they cannot be painted
  77.         // with Attribute paint tool till we support color painting.
  78.         if( $buf[2] == "vertexColorRGB" || $buf[2] == "vertexFaceColorRGB") {
  79.             continue ;
  80.         }
  81.         
  82.         string $isPaintableCmd = "makePaintable -q " + $buf[0] + " " + $buf[2];
  83.  
  84.         int $isPaintable[] = eval($isPaintableCmd);
  85.         if (size($isPaintable) < 1) {
  86.             continue;
  87.         }
  88.  
  89.         if ($isPaintable[0]) {
  90.             artAttrSelected( $artCmd, $attr );
  91.             return 1;
  92.         }
  93.     }
  94.  
  95.     return 0 ;
  96.  
  97. }
  98.  
  99. global proc int artAttrSetPaintableNode()
  100. {
  101.     source "artAttrCallback.mel";
  102.  
  103.     string $artCmd = "artAttrCtx";
  104.  
  105.     global string $gArtAttrCurrentAttr;
  106.  
  107.     if ( $gArtAttrCurrentAttr != "" ) {
  108.  
  109.         // Verify that this attribute is still a valid selection.
  110.         if ( artAttrValidateAttr( $gArtAttrCurrentAttr ) ) {
  111.             artAttrSelected( $artCmd, $gArtAttrCurrentAttr );
  112.             return 1;
  113.         }
  114.  
  115.         $gArtAttrCurrentAttr = "";
  116.     }
  117.  
  118.     return artAttrFindFirstPaintableAttr();
  119. }
  120.  
  121. global proc int artAttrInitPaintableAttr() 
  122. {
  123.     source "artAttrCallback.mel";
  124.  
  125.     global string $gArtAttrCurrentAttr;
  126.  
  127.     $gArtAttrCurrentAttr = "";
  128.  
  129.     return artAttrFindFirstPaintableAttr() ;
  130. }
  131.